package com.rongxun.hbwallet.ui.activities;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.rongxun.base.MvpActivity;
import com.rongxun.hbwallet.R;
import com.rongxun.hbwallet.model.entity.DealInfo;
import com.rongxun.hbwallet.mvp.contract.IDealMessage;
import com.rongxun.hbwallet.mvp.model.ApiModel;
import com.rongxun.hbwallet.mvp.presenter.DealMessagePresenter;
import com.rongxun.hbwallet.ui.adapter.DealMessageAdapter;
import com.rongxun.utils.StatusBarUtil;

import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 创建者     庄丰泽
 * 创建时间   2018/8/10 10:38
 * 描述	     交易记录
 */
public class DealMessageActivity extends MvpActivity<IDealMessage.IView,DealMessagePresenter> implements IDealMessage.IView{
    @BindView(R.id.deal_message_rv)
    RecyclerView mRecyclerView;
    @BindView(R.id.toolbar_title)
    TextView     mToolbarTitle;
    @BindView(R.id.toolbar_back)
    ImageView    mToolbarBack;
    @BindView(R.id.toolbar)
    Toolbar      mToolbar;
    private DealMessageAdapter mAdapter;
    @Override
    protected void init() {
        StatusBarUtil.setToolBarPaddingTop(mToolbar, this);
        mToolbarBack.setVisibility(View.VISIBLE);
        mToolbarTitle.setText(getString(R.string.deal_record));
        getPresenter().setAdapterData();
    }
    @Override
    protected int getContentView() {
        return R.layout.activity_dealmessage;
    }

    @Override
    public Context getContext() {
        return this;
    }

    @Override
    public void showLoading(boolean show) {

    }

    @Override
    public void showError(String msg, String errorCode) {

    }

    @Override
    public void checkPermissionsSuccessful(String... permissions) {

    }

    @Override
    public void release() {

    }

    @NonNull
    @Override
    public DealMessagePresenter createPresenter() {
        return new DealMessagePresenter(this,new ApiModel(this));
    }

    @Override
    public void setAdapterData(List<DealInfo> mlist) {
        mAdapter=new DealMessageAdapter(R.layout.item_dealmessage,mlist);
        LinearLayoutManager manager=new LinearLayoutManager(this);
        manager.setOrientation(LinearLayoutManager.VERTICAL);
        mRecyclerView.setLayoutManager(manager);
        mRecyclerView.setAdapter(mAdapter);
    }
    @OnClick({R.id.toolbar_back})
    public void onViewClicked(View view) {
        switch (view.getId()){
            case R.id.toolbar_back:
                onBackPressed();
                break;
        }
    }
}
